﻿using UnityEngine;
using System.Collections;
using ngnclht;

public class Ball : MonoBehaviour {
	public int xGrid;
	public int yGrid;

	public int ballColor;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

	}
	// tinh toan ra toa do cua Grid tu toa do thuc
	void detechGridPos(){
		this.xGrid =(int) (gameObject.transform.localPosition.x / (Define.widthBetweenTwoSquare + Define.widthOfGridSquare));
		this.yGrid =(int) (gameObject.transform.localPosition.y / (Define.heightOfGridSquare    + Define.heightOfGridSquare));
	}

	// di chuyen den toa do cua grid
	void transformToGridPos(int xGrid, int yGrid){
		this.setXGrid (xGrid);
		this.setYGrid (yGrid);
		float xReal = xGrid * (Define.widthBetweenTwoSquare + Define.widthOfGridSquare);
		float yReal = yGrid * (Define.heightOfGridSquare    + Define.heightOfGridSquare);
	}

	public void setXGrid(int xGrid){
		this.xGrid = xGrid;
	}

	public void setYGrid(int yGrid){
		this.yGrid = yGrid;
	}
}
